home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Hardware / Misc. Tools / LFSR Verilog CAD Tool / Vert Count < prev   
Encoding:
Text File  |  1993-06-03  |  1.8 KB  |  56 lines  |  [TEXT/OIUB]

  1. `timescale 1 ns / 100 ps
  2. /* Linear Feedback Shift Register 
  3.  * verilog module "VCOUNT"
  4.  * Generated by Macintosh application 'LFSR' 5/17/93 1:32 PM 
  5.  * company: Apple Computer 
  6.  * project: Display Controller 
  7.  * designer: Elmer Fudd
  8.  * prototypes:
  9.    VCOUNT(clk, NextLine, preset, Frame);
  10.    VCOUNT(.clk(CLOCK), .NextLine(CE), .preset(PRESET), .Frame(TC));
  11.  *
  12.  * The counter reaches terminal count after 480 positive edge clocks. 
  13.  * 'Frame' is asserted high at the end of count.
  14.  * count is preset synchronously by an active high on 'preset'.
  15.  * The counter is free running. It presets itself on every terminal count. 
  16.  * The counting is suspended when 'NextLine' is asserted low.
  17.  * The counter uses AND (or NAND) gates on the output of the shift register to detect for terminal count of all 'ones'.
  18.  * The main counter consist of 9 registers with 2 taps feedback to the input. 
  19.  */
  20. module VCOUNT (clk, NextLine, preset, Frame);
  21. input clk; 
  22. input NextLine; 
  23. input preset; 
  24. output Frame; 
  25. reg [8:0] D;
  26. reg  [8:0] Q;
  27.  
  28. assign Frame = &Q; 
  29.  
  30. always @(Q or preset or Frame or NextLine)
  31.     begin
  32.         casex ({preset, Frame, NextLine}) // synopsys parallel_case full_case
  33.             'b??0:
  34.                 begin
  35.                     D = Q;        // suspend counting
  36.                 end
  37.             'b1?1,            // preset to value
  38.             'b?11:            // retrigger presets from TC
  39.                 begin
  40.                     D = 'h16F; // preset to seed
  41.                 end
  42.             'b001:           // normal counting
  43.                 begin
  44.                     D[8:1] = Q[7:0];
  45.                     D[0] = Q[8] ^ Q[3];
  46.                 end
  47.         endcase
  48.     end // always
  49.     
  50. // Shift register description
  51. always @(posedge clk)
  52.     begin
  53.         Q = D;     // make into D register
  54.     end
  55. endmodule // VCOUNT
  56.